// --------------------------------------------------------------------------------------------------------------------
// <copyright file="Tag.cs" company="ecblog.codeplex.com">
//   emrecoskun.net - ibrahimatay.com
// </copyright>
// <summary>
//   The tag
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace EcBlog.Models
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel.DataAnnotations;
    
    // using System.ComponentModel.DataAnnotations.Schema;
    using System.Web.Mvc;

    using EcBlog.Properties;

    /// <summary>
    /// The tag
    /// </summary>
    public sealed class Tag
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="Tag"/> class.
        /// </summary>
        public Tag()
        {
            this.Pages = new HashSet<Page>();
        }

        /// <summary>
        /// Gets or sets the tag id.
        /// </summary>
        /// <value>
        /// The tag id.
        /// </value>
        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public long TagId { get; set; }

        /// <summary>
        /// Gets or sets the pages.
        /// </summary>
        /// <value>
        /// The pages.
        /// </value>
        [ScaffoldColumn(false)]
        public ICollection<Page> Pages { get; set; }

        /// <summary>
        /// Gets or sets the name of the tag.
        /// </summary>
        /// <value>
        /// The name of the tag.
        /// </value>
        [Required][StringLength(50)]
        [Remote("CheckDuplicateTagName",
            "Tag",
            "Admin",
            AdditionalFields = "TagId",
            ErrorMessageResourceName = "CheckDuplicate", ErrorMessageResourceType = typeof(ModelLocalization))]
        public string TagName { get; set; }

        /// <summary>
        /// Gets or sets the tag slug.
        /// </summary>
        /// <value>
        /// The tag slug.
        /// </value>
        [StringLength(50)][Required]
        [Remote("CheckDuplicateTagSlug",
            "Tag",
            "Admin",
            AdditionalFields = "TagId",
            ErrorMessageResourceName = "CheckDuplicate", ErrorMessageResourceType = typeof(ModelLocalization))]
        public string TagSlug { get; set; }

        /// <summary>
        /// Gets or sets the last modified.
        /// </summary>
        /// <value>
        /// The last modified.
        /// </value>
        [ScaffoldColumn(false)]
        public DateTime LastModified { get; set; }

        /// <summary>
        /// Gets or sets the last modified user.
        /// </summary>
        /// <value>
        /// The last modified user.
        /// </value>
        [StringLength(50)][ScaffoldColumn(false)]
        public string LastModifiedUser { get; set; }
    }
}